# -*- coding:utf8 -*-
import os
import requests
from openpyxl import load_workbook
from openpyxl import workbook

base_dir = os.path.dirname(os.path.abspath(__file__))
filename = os.path.join(base_dir,"users.xlsx")
wb = workbook.Workbook()
wb.create_sheet(0)
sheet = wb.worksheets[0]
sheet.title = "用户信息"
sheet.sheet_properties.tabColor = "1072BA"
del wb["Sheet1"]
wb.save(filename)

wb = load_workbook(filename)
sheet = wb.worksheets[0]
cell_title =  sheet.cell(1,1)
cell_title.value = "姓名"
cell_title1 = sheet.cell(1,2)
cell_title1.value = "密码"
rows = 2

while True:
    name = input("输入用户名，输入Q|q退出: ")
    if name.upper() == "Q":
        break
    passwd = input("输入密码: ")
    u_cell = sheet.cell(rows,1)
    u_cell.value = name
    p_cell = sheet.cell(rows,2)
    p_cell.value = passwd
    rows += 1

wb.save(filename)